package com.wtwd.device.model.dto;


import cn.hutool.core.bean.BeanUtil;
import com.wtwd.device.constant.Constant;
import com.wtwd.device.model.entity.AppUserTarget;
import io.swagger.annotations.ApiModelProperty;

/**
 * Created by Roc on 2021/8/18.
 * 目标信息
 */
public class TargetInfo {

    /**
     * 设备ID
     */
    @ApiModelProperty(value = "用户ID")
    private long userId;
    /**
     * 睡眠目标：小时
     */
    @ApiModelProperty(value = "睡眠小时")
    private int sleepHour = 7;
    /**
     * 睡眠目标：分钟
     */
    @ApiModelProperty(value = "睡眠分钟")
    private int sleepMinute;
    /**
     * 步数目标
     */
    @ApiModelProperty(value = "步数")
    private int stepNumber = 10000;
    /**
     * 运动距离目标
     */
    @ApiModelProperty(value = "运动距离")
    private int sportDistance = 100000;
    /**
     * 运动时间目标：小时
     */
    @ApiModelProperty(value = "运动时长小时")
    private int sportHour = 2;
    /**
     * 运动时间目标：分钟
     */
    @ApiModelProperty(value = "运动时长分钟")
    private int sportMinute;
    /**
     * 卡路里目标
     */
    @ApiModelProperty(value = "卡路里(kcal)")
    private int sportCalories = 12;

    public int getSportCalories() {
        return sportCalories;
    }

    public void setSportCalories(int sportCalories) {
        this.sportCalories = sportCalories;
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public int getSleepHour() {
        return this.sleepHour;
    }

    public void setSleepHour(int sleepHour) {
        this.sleepHour = sleepHour;
    }

    public int getSleepMinute() {
        return this.sleepMinute;
    }

    public void setSleepMinute(int sleepMinute) {
        this.sleepMinute = sleepMinute;
    }

    public int getStepNumber() {
        return this.stepNumber;
    }

    public void setStepNumber(int stepNumber) {
        this.stepNumber = stepNumber;
    }

    public int getSportDistance() {
        return this.sportDistance;
    }

    public void setSportDistance(int sportDistance) {
        this.sportDistance = sportDistance;
    }

    public int getSportHour() {
        return this.sportHour;
    }

    public void setSportHour(int sportHour) {
        this.sportHour = sportHour;
    }

    public int getSportMinute() {
        return this.sportMinute;
    }

    public void setSportMinute(int sportMinute) {
        this.sportMinute = sportMinute;
    }

    public AppUserTarget toEntity() {
        AppUserTarget target = BeanUtil.copyProperties(this, AppUserTarget.class);
        target.setSleep(this.getSleepHour() * Constant.HH_TO_SS + this.getSleepMinute() * Constant.MM_TO_SS);
        target.setSportTime(this.getSportHour() * Constant.HH_TO_SS + this.getSleepMinute() * Constant.MM_TO_SS);
        return target;
    }

    public static TargetInfo toThis(AppUserTarget appUserTarget) {
        if (appUserTarget == null) return null;
        TargetInfo targetInfo = BeanUtil.copyProperties(appUserTarget, TargetInfo.class);
        Integer sleep = appUserTarget.getSleep();
        Integer sportTime = appUserTarget.getSportTime();
        targetInfo.setSleepHour(sleep / Constant.HH_TO_SS);
        targetInfo.setSleepMinute(sleep % Constant.HH_TO_SS / Constant.MM_TO_SS);
        targetInfo.setSportHour(sportTime / Constant.HH_TO_SS);
        targetInfo.setSportMinute(sportTime % Constant.HH_TO_SS / Constant.MM_TO_SS);
        return targetInfo;
    }


}
